<?php


namespace view;

class Date {
	
	/**
	 * @var array $today
	 * @var string $wday
	 * @var string $mon
	 * @var int $hour
	 * @var int $min
	 * @var int $sec
	 * @return string $date
	 */
	
	public static function getCorrectDate() {
		
		//Skapar ett datum
		$today = getdate();
		
		//Kollar veckodag
		if ($today["wday"] == "1") {
			$wday="Måndag";
		
		} 	else if ($today["wday"] == "2") {
			$wday="Tisdag";
		
		}	else if ($today["wday"] == "3") {
			$wday="Onsdag";
		
		}	else if ($today["wday"] == "4") {
			$wday="Torsdag";
		
		}	else if ($today["wday"] == "5") {
			$wday="Fredag";
		
		}	else if ($today["wday"] == "6") {
			$wday="Lördag";
		
		}	else if ($today["wday"] == "0") {
			$wday="Söndag";
		}
		
		
		//Kolla Månad och lägger rätt månad i en variabel
		if ($today["mon"] == "1") {
			$mon = "Januari";
	
		} 	else if ($today["mon"] == "2") {
			$mon = "Februari";
		
		}	else if ($today["mon"] == "3") {
			$mon = "Mars";
		
		}	else if ($today["mon"] == "4") {
			$mon = "April";
		
		}	else if ($today["mon"] == "5") {
			$mon = "Maj";
		
		}	else if ($today["mon"] == "6") {
			$mon = "Juni";
		
		}	else if ($today["mon"] == "7") {
			$mon = "Juli";
		
		}	else if ($today["mon"] == "8") {
			$mon = "Augusti";
		
		}	else if ($today["mon"] == "9") {
			$mon = "September";
		
		}	else if ($today["mon"] == "10") {
			$mon = "Oktober";
		
		}	else if ($today["mon"] == "11") {
			$mon = "November";
		
		}	else if ($today["mon"] == "12") {
			$mon = "December";
		
		}
		
		//Rättar Timmarna genom att lägga till en 0:a framför < 10
		if ($today["hours"] < "10") {
					
			$i = $today["hours"];
			$hour = "0" . $i;
		
		}	else {
			$hour = $today["hours"];
		}
		
			
		//Rättar Minuterna genom att lägga till en 0:a framför < 10
		if ($today["minutes"] < "10") {
					
			$i = $today["minutes"];
			$min ="0" . $i;
		
		}	else {
			$min = $today["minutes"]; 
		}
		
		//Rättar Sekunderna genom att lägga till en 0:a framför < 10
		if ($today["seconds"] < "10") {
					
			$i = $today["seconds"];
			$sec = "0" . $i;
		
		}	else {
			$sec = $today["seconds"];   
		}
		
		
	
$date = $wday . ", den " . $today["mday"] . " " . $mon . " år " . $today["year"] . ". Klockan är [" . $hour . ":". $min. ":" . $sec . "].";
			
		return $date;			
		
	}
}
 

